<template>
  <div class="app-container">
    <!-- <div class="wrap">
      <h2 class="box">年度工作量汇总</h2>
    </div> -->
    <el-row :gutter="12" style="margin-bottom: 20px;">
      <el-card :body-style="{ padding: '0px' }">
        <el-form
          ref="wellDrillingForm"
          :inline="true"
          :model="wellDrillingParams"
          class="demo-form-inline"
          style="margin-left: 20px;"
            >
          <el-form-item label="投资" prop="tztype" >
            <el-select v-model="wellDrillingParams.tztype" placeholder="投资" filterable style="width: 100%;">
              <el-option v-for="dict in tzData" :key="dict" :label="dict" :value="dict" />
              </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" :loading="wellDrillingLoading" @click="drawTermimg">绘图</el-button>
            <el-button type="success" @click="handleRestWellDrilling">重置</el-button>
          </el-form-item>
        </el-form>
        <div id="termEcharts" class="draw_div"></div>
      </el-card>
    </el-row>
    
  </div>
</template>

<script>
import echarts from "echarts";
import { foldLineHistogram, Histogram } from "@/utils/echartsDraw";
import { Decrypt } from "@/utils/AesHmacMD5";
import { getTermData,listRegionType1 } from "@/api/vadmin/budget/ledger/ledgerapi";

export default {
  name: "analterm",
  data() {
    return {
      currentDate: new Date(),tzData:['常规投资','非常规投资','总体投资'],
      wellDrillingParams: {
        tztype:'常规投资',
        wellName: '',
        kzrq:[],wzrq:[],wjrq:[]
      },
      wellDrillingLoading: false,
      wellDrillingBolWellOrFile: true
    };
  },
  mounted() {
    this.drawTermimg();
    this.getRegionList1();
  },
  methods: {
    /**
     * 绘制
     */
    drawTermimg() {
      this.wellDrillingLoading = true;
      getTermData(this.wellDrillingParams).then(response => {
        var titleList = ["2023", "2024"];
        var resData = JSON.parse(Decrypt(response.data));

        var element = document.getElementById("termEcharts");
        var myChart = echarts.init(element);

        Histogram(myChart, titleList, resData.x_weeks, resData.y_weeks);
        this.wellDrillingLoading = false;
      }).catch(error => {
        this.wellDrillingLoading = false;
      });
    },
    /**
     * 重置-探井工作量
     */
    handleRestWellDrilling() {
      this.wellDrillingParams = {
        type: "1",
        wellName: undefined,
        fileID: undefined,
        method: "1",
        startTime: undefined,
        endTime: undefined,
        completeTime: undefined,
        sum: undefined,
        footage: undefined
      };
      this.wellDrillingBolWellOrFile = true;
      this.resetForm("wellDrillingForm");
      this.drawTermimg();
    },
  }
};
</script>

<style>
.time {
    font-size: 13px;
    color: #999;
}

.bottom {
    margin-top: 13px;
    line-height: 12px;
}

.button {
    padding: 0;
    float: right;
}

.image {
    width: 100%;
    display: block;
}

.clearfix:before,
.clearfix:after {
    display: table;
    content: "";
}

.clearfix:after {
    clear: both;
}

.wrap {
    text-align: center;
    /* background-color: #6c6b6b; */
    height: 50px;
    margin-bottom: 10px;
    background-color: #FF3CAC;
    background-image: linear-gradient(225deg, #FF3CAC 0%, #784BA0 50%, #2B86C5 100%);
}

.box {
    color: aliceblue;
    line-height: 50px;
}

.drawDiv {
    float: right;
    line-height: 60px;
}

.draw_div {
    height: 500px;
    width: 100%;
    margin-top: 20px;
}
</style>
